﻿//////////////////////////////////////////////////////////////////
//
// SallyCity.cs
//
// Copyright (c) 2012 Dan Pike. All rights reserved
//
// Refer to license.txt for any license restrictions.
// 
using Entities;
using Entities.Cities;
using Logger4Net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Sally
{
   //////////////////////////////////////////////////////////////////////////
   /// <summary>
   /// 
   /// </summary>
   public class SallyCity
   {
      //////////////////////////////////////////////////////////////////////////
      /// <summary>
      /// 
      /// </summary>
      public SallyCity()
      {
      }

      //////////////////////////////////////////////////////////////////////////
      //
      public bool initialize(World world, Main gui, City city)
      {
         try
         {
            world_ = world;
            gui_ = gui;
            city_ = city;

            item_ = gui_.viewCity.Items.Add(city.name);
            item_.Tag = this;
            item_.SubItems.Add(string.Empty).Tag = 0; // Qty column
            return true;
         }
         catch (System.Exception ex)
         {
            logger_.exception(ex);
         }
         return false;
      }

      //////////////////////////////////////////////////////////////////////////
      //
      public void shutdown()
      {
         try
         {
            if (null != item_)
            {
               gui_.viewCity.Items.Remove(item_);
               item_ = null;
            }
         }
         catch (System.Exception ex)
         {
            logger_.exception(ex);
         }
      }

      //////////////////////////////////////////////////////////////////////////
      //
      public City city
      {
         get { return city_; }
         set { city_ = value; }
      }

      //////////////////////////////////////////////////////////////////////////
      //
      public ListViewItem item { get { return item_; } }

      //////////////////////////////////////////////////////////////////////////
      //
      private static Logger logger_ = new Logger(typeof(SallyCity));
      private World world_;
      private Main gui_;
      private City city_;
      private ListViewItem item_;
   }
}
